package cn.com.dcsgo.controller;

import cn.com.dcsgo.entity.response.ResponseResult;
import cn.com.dcsgo.mapper.UserMapper;
import cn.com.dcsgo.pojo.User;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * UserController
 *
 * @author Dcsgo
 * @since 2025/3/4 15:14
 */
@RestController
@RequestMapping("user")
@Api(value = "UserController",tags = "用户接口")
public class UserController {
    private final UserMapper userMapper;

    public UserController(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @GetMapping("demo")
    public ResponseResult<String> demoMethod() {
        return ResponseResult.success("Hello!");
    }

    @GetMapping("{id}")
    @Operation(summary = "通过id查询", description = "通过用户编号查询用户信息")
    public ResponseResult<User> findOne(@PathVariable Long id) {
        return ResponseResult.success(userMapper.selectById(id));
    }
}
